<template>
<div>
    <h1>登录</h1>
    <table class="table">
        <tr>
            <td>账号</td>
            <td><input type="text" v-model="data.name"></td>
        </tr>

        <tr>
            <td>密码</td>
            <td><input type="password" v-model="data.pwd"></td>
        </tr>

        <tr>
            <td></td>
            <td><input type="button" value="登录" @click="Login()"></td>
        </tr>

    </table>
</div>

</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router=useRouter()

const data=ref({
     name:'',
     pwd:''
})


const Login=()=>{
    axios.get("/api/House/Login",{params:data.value}).then(res=>{
        if(res.data.id>0){
            alert("登录成功");
            router.push("/Add")
        }else{
            alert("登录失败");
        }
    })
}
        
</script>

<style lang="scss" scoped>

</style>